﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using ZFSData;
using ZFSData.Manager;
using ZFSInterface.User;

namespace ZFSBusiness
{

    /// <summary>
    /// 用户管理
    /// </summary>
    public class UserManager : BaseManager<UserManager>, IUser
    {
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="account"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public tb_User Login(string account, string password)
        {
            return factoryManager.GetUserManager().Login(account, password);
        }

        /// <summary>
        /// 退出
        /// </summary>
        /// <param name="account"></param>
        public void Logout(string account)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 获取用户权限
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public List<View_UserAuthority> GetAuthority(string account)
        {
            return factoryManager.GetUserManager().GetAuthority(account);
        }

        public tb_User GetModelByAccount(string account)
        {
            return factoryManager.GetUserManager().GetModelByAccount(account);
        }

        public List<tb_User> GetModels(Expression<Func<tb_User, bool>> whereLambda)
        {

            return factoryManager.GetUserManager().GetModels(whereLambda);
        }

        public List<tb_User> GetPagingModels<S>(int pageIndex, int pageSize, out int totalCount,
            Expression<Func<tb_User, bool>> whereLambda, Expression<Func<tb_User, S>> orderbyLambda, bool Asc = false)
        {

            return factoryManager.GetUserManager().GetPagingModels(pageIndex, pageSize, out totalCount, whereLambda, orderbyLambda, Asc);
        }

        public bool DeleteEntity(tb_User entity)
        {

            return factoryManager.GetUserManager().DeleteEntity(entity);
        }

        public bool UpdateEntity(tb_User entity)
        {
            return factoryManager.GetUserManager().UpdateEntity(entity);
        }

        public tb_User AddEntity(tb_User entity)
        {
            return factoryManager.GetUserManager().AddEntity(entity);
        }

        public bool ExistEntity(Expression<Func<tb_User, bool>> whereLambda)
        {
            FactoryManager f = new FactoryManager();
            return factoryManager.GetUserManager().ExistEntity(whereLambda);
        }
    }
}
